function msg_plus1(event) {
  var element = $(".bubble").first();
  console.log("plugin-plus1_msg")
  $("#plus1").remove();
  element.append("<button id='plus1' style='margin: 1em auto;padding: .3em .5em;border-radius: 50%'>+1</button>");
  $("#plus1").click(function (msg) {
    return function () {
      drrr.print(msg);
    }
  }(event.text));
}

function me_plus1(event) {
  var element = $('#talks div').first();
  console.log("plugin-plus1_me")
  $("#plus1").remove();
  element.append("<button id='plus1' style='margin: 0 10px;padding: 0 .5em;border: 0;border-radius: 25px'>+1</button>");
  $("#plus1").click(function (msg) {
    return function () {
      $.ajax({
        url: "https://drrr.com/room/?ajax=1",
        method: "POST",
        data: {
          message: "/me " + msg
        }
      })
    }
  }(event.text));
}

function plus1(event) {
  console.log("plugin-plus1 event: ")
  console.log(event)

  if (event.type === "msg") {
    msg_plus1(event)
  } else if (event.type === "me") {
    me_plus1(event)
  }
}

$("head").append(
    `<style>
      #plus1 {
        position: absolute;
        display: inline-block;
        background-image: linear-gradient(#f5c153, #ea920d);
        border: 1px solid rgba(0,0,0,.2);
        box-shadow: 0 1px white inset;
        text-align: center;
        text-shadow: 0 1px 1px black;
        color:white;
        font-weight: bold;
      }
      #plus1:active {
        box-shadow: .05em .1em .2em rgba(0,0,0,.6) inset;
        border-color: rgba(0,0,0,.3);
        background: #ea920d;
      }
    </style>`
);
plugin_hooks.push(plus1);